<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <ul id="parent">
    <li id="1">1</li>
    <li id="2">2</li>
    <li id="3">3</li>
  </ul>

  <script>
    /**
     * js事件委托，将click事件委托给父级元素统一处理
     */
    document.getElementById("parent").addEventListener('click',function(e){
      const target = e.target;
      if(target.nodeName.toLocaleLowerCase() == 'li'){
        console.log(target.id);
      }
    })
  </script>
</body>
</html>